<?php

namespace catchAdmin\hunqing\tables;

use catchAdmin\hunqing\tables\forms\Factory;
use catcher\CatchTable;
use catcher\library\table\Actions;
use catcher\library\table\HeaderItem;
use catcher\library\table\Search;

class Userinfos extends CatchTable
{

    public function table()
    {
        $userOptions = [
            [
                'value' => 1,
                'label' => '30天未跟进'
            ],
            [
                'value' => 2,
                'label' => '全部'
            ],

        ];

        return $this->getTable('userinfos')
            ->header([
                HeaderItem::label('')->selection(),
                HeaderItem::label('会员名')->prop('name')->width(80),
                HeaderItem::label('性别')->prop('sex')->width(60),
//                HeaderItem::label('手机')->prop('lianxi'),
                HeaderItem::label('出生年月')->prop('shengri')->width(120),
                HeaderItem::label('会员状态')->prop('vip')->withSwitchComponent()->width(60),
                HeaderItem::label('会员提醒')->prop('viptime')->width(140),
                HeaderItem::label('注册时间')->prop('created_at')->width(130),
                HeaderItem::label('车')->prop('che')->withSwitchComponent()->width(60),
                HeaderItem::label('车贷')->prop('chedai')->withSwitchComponent()->width(60),
                HeaderItem::label('房')->prop('fang')->withSwitchComponent()->width(60),
                HeaderItem::label('房贷')->prop('fangdai')->withSwitchComponent()->width(60),
                HeaderItem::label('跟进老师')->prop('laoshi')->width(100),
                HeaderItem::label('属相')->prop('shuxiang')->width(60),
                HeaderItem::label('照片')->prop('image')->withPreviewComponent(),
                HeaderItem::label('身份证')->prop('image1')->withPreviewComponent(),
                HeaderItem::label('户口本')->prop('image2')->withPreviewComponent(),
                HeaderItem::label('操作')->width(330)->actions([
                    Actions::update()->hiddenFiled('b'),
                    Actions::delete()->hiddenFiled('e'),

                    Actions::normal('跟进','success','genjin')->hiddenFiled('f'),
                    Actions::normal('查看','zz4','view'),

                ])
            ])
            ->withSearch([
                Search::label('会员名')->text('name', '姓名'),
                Search::label('手机号')->text('lianxi', '手机号'),
                Search::label('出生年月')->text('chusheng', '出生年'),
                Search::label('老师')->text('laoshi', '老师'),
                Search::label('跟进状态:')->radio('gx', $userOptions)->button(),
                Search::label('会员状态:')->radio('vip', [
                    [
                        'value' => 1,
                        'label' => '会员'
                    ],
                    [
                        'value' => 2,
                        'label'=> '非会员'
                    ]
                ])->button(),

                Search::label('性别')->radio('sex', [
                    [
                        'label'=>'男',
                        'value'=>'1'
                    ],
                    [
                        'label'=>'女',
                        'value'=>'0'
                    ],

                ])->button(),

                Search::label('婚姻状态')->select('hunyin', 0,[
                    [
                        'label'=>'未婚',
                        'value'=>'0'
                    ],
                    [
                        'label'=>'离异',
                        'value'=>'1'
                    ],
                    [
                        'label'=>'丧偶',
                        'value'=>'2'
                    ],
                    [
                        'label'=>'短婚未育',
                        'value'=>'3'
                    ]
                ]),

            ])
            ->withImportRoute('/userinfos/import')
            ->withApiRoute('userinfos')
            ->withActions([
                Actions::create(),
                 Actions::import(),

            ])


            ->selectionChange()
            ->render();

    }

    public function form()
    {
        return Factory::create('userinfos');

    }

}


